home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Otherware
/
Otherware_1_SB_Development.iso
/
mac
/
hypercar
/
xcmd
/
newfolde.sit
/
NF Source
/
NewFolder.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-04-03
|
2KB
|
114 lines
/*
NewFolder - Create a new folder
This XCMD is Copyright 1990, by David Elliott.
*/
#include "HyperXCmd.h"
#include <SetUpA4.h>
#include <FileMgr.h>
/* Constants */
#define NULL 0L
#define FALSE 0
#define TRUE 1
/* Macros */
#define strlen(s) StringLength(paramPtr, (StringPtr) (s))
#define pasToZero(s) PasToZero(paramPtr, (StringPtr) (s))
#define zeroToPas(s1,s2) ZeroToPas(paramPtr, (char *) (s1), \
(StringPtr) (s2))
#define numToStr(l,s) NumToStr(paramPtr, (long) (l), s)
/* Static variables */
static char sWrongArgs[] = "\pWrong number of arguments";
/* Prototypes */
pascal void main(XCmdBlockPtr);
int CreateFolder(char *);
pascal void main(paramPtr)
XCmdBlockPtr paramPtr;
{
int err;
int lasterr;
int pnum;
Str31 str;
int bigerr = 0;
RememberA0();
SetUpA4();
pnum = 0;
while (pnum < paramPtr->paramCount) {
err = CreateFolder(*paramPtr->params[pnum]);
if (err) {
bigerr = err;
}
pnum++;
}
if (bigerr) {
numToStr(bigerr, &str);
paramPtr->returnValue = pasToZero(str.guts);
}
RestoreA4();
}
int CreateFolder(name)
char *name;
{
ParamBlockRec params;
int err;
char *cp;
char savec;
params.fileParam.ioCompletion = NULL;
params.fileParam.ioResult = 0;
params.fileParam.ioVRefNum = -1;
params.fileParam.ioFlNum = 0;
err = 0;
cp = name;
/*
* Get past first :, since that is the name of the
* volume.
*/
while (*cp != ':') {
if (*cp == '\0') {
return 0;
}
cp++;
}
cp++;
for ( ; ; ) {
if (*cp == ':' || *cp == '\0') {
savec = *cp;
*cp = '\0';
} else {
cp++;
continue;
}
CtoPstr(name);
params.fileParam.ioNamePtr = (StringPtr)name;
PBDirCreate(¶ms, FALSE);
err = params.fileParam.ioResult; /* Last error found is returned */
PtoCstr(name);
if (savec == '\0') {
return err;
}
*cp = savec;
cp++;
}
return err;
}
/* C routines for HyperCard callbacks */
#include "XCmdGlue.inc.c"